#include "communication_protocol.h"
#include "ble_nus.h"
#include <stdio.h>

#include "user_fifo.h"


//void set_complete_callback(SendCompletePara para);

uint8_t g_buffer[20] = {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};

extern ble_nus_t  m_nus;

//static Data_packet_t data_packet;
   
int count = 0;

void resend(void * contenxt)
{
//    SendCompletePara sendPara;
//    uint32_t error_code = NRF_SUCCESS;

//    
////    error_code = ble_nus_string_send(&m_nus,g_buffer,20);

////    if(error_code == NRF_SUCCESS)
////    {
////        sendPara.callback = resend;
////        sendPara.context = &g_buffer;
////        set_complete_callback(sendPara);
////        return;
////    }
//    
//    while(error_code == NRF_SUCCESS && count <= 6)
//    {
////        if(0 == pop_data(&data_fifo, &data_packet))
////        {
////            error_code = ble_nus_string_send(&m_nus,data_packet.data_byte,20);
////            if((error_code != NRF_SUCCESS))
////            {
////                break;
////            }
////        }

//        //if(error_code == BLE_ERROR_NO_TX_BUFFERS)

////        g_buffer[19]++;
//        count++;
//    }
//    
//    printf("send count: %d, err: %X, p_enable:%d\r\n", count, error_code, m_nus.is_notification_enabled);
//    
////    count = 0;
//    
//    if(error_code == BLE_ERROR_NO_TX_BUFFERS)
//    //if(error_code != NRF_SUCCESS)
//    {
//        sendPara.callback = resend;
//        sendPara.context = &g_buffer;
////        set_complete_callback(sendPara);
//    }
}
